﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ledict.ConditionExtract
{
    public class Log
    {
        static private string path = System.Environment.CurrentDirectory + "\\log.txt";

        static private bool createFile()
        {
            try
            {
                if (File.Exists(path))
                {
                    return true;
                }
                else
                {
                    File.Create(path);
                }
                return true;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return false;
            }
        }
        /// <summary>
        /// 记日志到log文件
        /// </summary>
        /// <param name="msg"></param>
        static public void WriteLog(string msg)
        {
            try
            {
                string dateTime = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                File.AppendAllText(path, dateTime + "\r\n");
                File.AppendAllText(path, msg + "\r\n");
                Console.WriteLine(dateTime);
                Console.WriteLine(msg);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}
